<template>
  <div class="page">
    <!-- 搜索区域 开始 -->
    <div class="el_card_box">
      <el-form :inline="true" size="small" :model="formInline" class="search_form">
        <el-form-item label="预约医生：">
          <!-- <el-select v-model="formInline.doctorName" filterable>
            <el-option v-for="(item,index) in doctorList" :key="index" :label="item.doctorName" :value="item.doctorName"></el-option>
          </el-select> -->
          <doctor-select v-model="formInline.doctorId" />
        </el-form-item>
        <el-form-item label="关键词：">
          <el-input v-model="formInline.key" placeholder="预约人、电话"></el-input>
        </el-form-item>
      </el-form>
      <div class="search_btn_box">
        <el-button type="primary" size="small" @click="getList">筛选</el-button>
        <el-button type="default" size="small" @click="rest">清空筛选</el-button>
      </div>
    </div>
    <!-- 搜索区域 end -->

    <!-- 表格 开始 -->
    <div class="table_box">
      <el-table ref="elTable" class="el_table" size="small" :data="tableData">
        <el-table-column prop="doctorName" label="预约医生" />
        <el-table-column prop="patientName" label="预约人" show-overflow-tooltip />
        <el-table-column prop="phoneNumber" label="电话" show-overflow-tooltip />
        <el-table-column prop="appointmentTime" label="预约时间" show-overflow-tooltip />
        <el-table-column prop="authorizationNumber" label="授权号码" show-overflow-tooltip />
        <el-table-column prop="createdAt" label="下单时间" show-overflow-tooltip />
      </el-table>
      <div class="pagination_list">
        <el-pagination background layout="sizes, total,prev, pager, next, jumper" :total="pageTotal" :page-size="pageSize" :page-sizes="pageSizes" :current-page.sync="pageNumber" @current-change="getList" @size-change="changePageSize" />
      </div>
    </div>
    <!-- 表格 end -->
  </div>
</template>
    
<script>
import { GET_APPOINTMENT_LIST } from "@/http/interface";
import DoctorSelect from "@/components/doctor/select.vue";
export default {
  components: {
    DoctorSelect,
  },
  data() {
    return {
      formInline: {},
      tableData: [],
      pageTotal: 0,
      pageNumber: 1,
      pageSizes: [10, 20, 50, 100],
      pageSize: 20,
      loading: false,
      doctorList: [],
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    /** 重置 */
    rest() {
      this.formInline = {};
      this.getList();
    },

    /** 每页展示 */
    changePageSize(e) {
      this.pageSize = e;
      this.getList();
    },

    /** 获取参数 */
    getParams() {
      let oParams = JSON.parse(JSON.stringify(this.formInline));
      let n = this.orderTime;

      if (n && n.length > 0) {
        oParams.sDate = n[0];
        oParams.eDate = n[1];
      }

      oParams.current = this.pageNumber;
      oParams.size = this.pageSize;
      return oParams;
    },

    /** 获取列表 */
    getList() {
      let _this = this;
      let oParams = this.getParams();
      GET_APPOINTMENT_LIST(oParams).then((res) => {
        let obj = res.data || {};
        _this.tableData = obj.records || [];
        _this.pageTotal = obj.total;
      });
    },
  },
};
</script>
    
    <style lang="scss" scoped>
@import "@/assets/style/customer/index.scss";
</style>
    